package cn.mysocketnet.a08test2;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //客户端：发送一条数据，接收服务端反馈的消息并打印
        //服务器：接收数据并打印，再给客户端反馈消息
        ServerSocket ss = new ServerSocket(10000);
        Socket socket = ss.accept();
        InputStreamReader reader = new InputStreamReader(socket.getInputStream());
        char[] chars = new char[1024];
        int len;
        while ((len=reader.read(chars))!=-1){
            System.out.println(new String(chars,0,len));
        }

        socket.getOutputStream().write("hello client 吊毛".getBytes());
        ss.close();
    }
}
